<template>
  <div>
    <secQuestion ref="questionRef" :data="questions" :customRule="rules" :card="true">
      <div class="question-card-title" slot="card-title">答题卡</div>
      <div slot="card-btn">
        <el-tooltip class="item" effect="dark" content="提交后查看审计要求" placement="top">
          <el-button type="primary" class="submit-que" @click="watchResult">查看结果</el-button>
        </el-tooltip>
      </div>
      <div class="question-title" slot="title">敏感场景配置</div>
    </secQuestion>
  </div>
</template>

<script>
import { consultDetailAnswerApi, consultDetailSaveApi } from "api/consultApi";
export default {
  name: "consultConfig",
  props: {},
  components: {},
  data() {
    return {
      rules: true,
      data: {},
      questions: [],
      consultId: "",
    };
  },
  computed: {},
  mounted() {
    this.consultId = this.$route.query.consultId;
    consultDetailAnswerApi({ id: this.consultId }).then((res) => {
      this.data = res.data;
      this.questions = this.data.questions;
    });
  },
  methods: {
    watchResult() {
      let data = this.$refs.questionRef.submit();
      if (!data) return; //有必填项没填写，如果都填写了，data是选择过的data数据
      consultDetailSaveApi({ consultId: this.consultId, answers: data }).then((res) => {
        let state = this.message.state(res);
        if (!state) return;
        this.utils.$router({ path: "/consult/detail", query: { id: this.consultId, tab: "tab1" } });
      });
    },
  },
  watch: {},
};
</script>
<style lang="scss" scoped>
//@import url(); 引入公共css类
@import "@/styles/question.scss";
</style>
